package co.fitstart.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.course.schedule.TargetData;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.bwh.BwhRecord;
import co.fitstart.entity.user.inbody.InbodyRecord;

/**
 * 
 * @author lidan
 *
 */
@Dynamic("hibernate")
public interface InbodyRecordDao {
    
    /**
     * list InbodyRecord by user
     * @param user
     * @return
     */
    @Query("FROM InbodyRecord WHERE disabled = false AND user = :user ORDER BY recordTime DESC")
    public List<InbodyRecord> listInbodyRecord(@Variable("user") User user);
    
    /**
     * 
     * @param mobile
     * @param recordTime
     * @return
     */
    @Query("FROM InbodyRecord WHERE disabled = false AND mobile = :mobile AND recordTime = :recordTime")
    public InbodyRecord load(@Variable("mobile") String mobile, @Variable("recordTime") String recordTime);
    
    /**
     * @param user
     * @return
     */
    @Query("FROM InbodyRecord WHERE disabled = false AND user = :user AND recordTime BETWEEN :start AND :end ORDER BY recordTime DESC")
    public List<InbodyRecord> listInbodyRecord(@Variable("user") User user, @Variable("start") String start, @Variable("end") String end);

    /**
     * @param user
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND user = :user AND recordTime BETWEEN :start AND :end AND disabled = false ORDER BY recordTime DESC")
    public List<BwhRecord> listBwhRecord(@Variable("user") User user, @Variable("start") String start, @Variable("end") String end);
    
    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND courseRound = :courseRound ORDER BY recordTime DESC")
    public List<BwhRecord> listBwhRecord(@Variable("courseRound") CourseRound courseRound);

    /**
     * 
     * @param mobile
     * @return
     */
    @Query("FROM InbodyRecord WHERE disabled = false AND user = :user ORDER BY recordTime DESC")
    public InbodyRecord load(@Variable("user") User user);

    /**
     * 
     * @return
     */
    @Query("FROM TargetData")
    public TargetData loadTargetData();
}
